package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseTeacherControllerApi;
import com.xuecheng.api.content.model.dto.CourseTeacherDTO;
import com.xuecheng.api.content.model.qo.QueryCourseTeacherModel;
import com.xuecheng.api.content.model.vo.CourseTeacherVO;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.content.convert.CourseTeacherConvert;
import org.springframework.web.bind.annotation.*;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.security.Security;
import java.util.List;

/**
 * <p>
 * 课程-教师关系表 前端控制器
 * </p>
 *
 * @author wyy
 */
@Slf4j
@RestController
public class CourseTeacherController implements CourseTeacherControllerApi {

    @Autowired
    private CourseTeacherService  courseTeacherService;


        @GetMapping("/courseTeacher/list/{courseBaseId}")
    public List<CourseTeacherDTO> queryCourseTeacherList(@PathVariable Long courseBaseId) {
        Long companyId = SecurityUtil.getCompanyId();
        return courseTeacherService.queryCourseTeacherList(courseBaseId,companyId);
    }

    @Override
    @PostMapping("/courseTeacher")
    public CourseTeacherDTO createOrModifyCourseTeacher(@RequestBody CourseTeacherVO vo) {
        Long companyId = SecurityUtil.getCompanyId();
        CourseTeacherDTO courseTeacherDTO = CourseTeacherConvert.INSTANCE.vo2dto(vo);

        return courseTeacherService.createOrModifyCourseTeacher(courseTeacherDTO,companyId);
    }

    @Override
    @DeleteMapping("/courseTeacher/course/{courseBaseId}/{courseTeacherId}")
    public boolean removeCourseTeacher(@PathVariable Long courseBaseId ,@PathVariable Long courseTeacherId) {
        Long companyId = SecurityUtil.getCompanyId();
        return courseTeacherService.removeCourseTeacher(courseTeacherId,courseBaseId,companyId);
    }
}